package com.example.codingchallenge;

import com.att.intern.webservice.Incident;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;

public class IncidentInformation extends Activity {
	
	private RadioButton backButton;
	private RadioButton logOffButton;
	private Button updateAddButton;
	private TextView buildingTV;
	private TextView glcTV;
	private TextView recTV;
	private TextView workReqTV;
	private TextView statusTV;
	
	private TextView incidentStatusTV;
	
	private Incident incident;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_incident_information);
		
		backButton = (RadioButton) findViewById(R.id.backRadioButton);
		logOffButton = (RadioButton) findViewById(R.id.logOffIncidentInformationRadioButton);
		updateAddButton = (Button) findViewById(R.id.updateAddButton);
		
		buildingTV = (TextView) findViewById(R.id.buildingTextView);
		glcTV = (TextView) findViewById(R.id.glcTextView);
		recTV = (TextView) findViewById(R.id.recTextView);
		statusTV = (TextView) findViewById(R.id.statusTextView);
		workReqTV = (TextView) findViewById(R.id.workReqTV);
		
		incidentStatusTV = (TextView) findViewById(R.id.incidentStatusTextView);
		
		Intent intent = getIntent();
		incident = (Incident) intent.getSerializableExtra("Incident");


		//System.out.println("InciReport: " + incident.getBuildingStatus());
		if (incident.getBuildingStatus().equals("OPEN"))
		{
			// Launch update screen
			updateAddButton.setText(R.string.update_incident_button);
			incidentStatusTV.setText("Report found!");
			
			buildingTV.setText("Building: " + incident.getBuildingName());
			glcTV.setText("GLC: " + incident.getGeoLoc());
			recTV.setText("Rec #: " + incident.getRecNumber());
			workReqTV.setText("Work Req: " + incident.getWorkReqNumber());
			statusTV.setText("Status: " + incident.getStatusNotes());
		
		}
		else
		{
			// Launch add screen
			updateAddButton.setText(R.string.add_incident_button);
			incidentStatusTV.setText("No report found.");
		}
	}

	public void exitActivity(View view)
	{
		finish();
	}
	
	public void logOff(View view)
	{
		MainActivity.logoff = true;
		finish();
	}

/*	public void addIncident(View view)
	{
		Intent intent = new Intent(this, AddIncident.class);
		intent.putExtra("incident", incident);
		startActivity(intent);
	}*/
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.incident_information, menu);
		return true;
	}

}
